<?php
/**
 * Created by PhpStorm.
 * User: 17828
 * Date: 2018/10/17
 * Time: 10:05
 */
namespace app\common\model;

use think\Model;

class DrivingcarLog extends Model
{
    public function getPersonalDriving($field,$where,$page,$limit){
        $data = $this->alias('dl')
            ->field($field)
            ->join('car c','c.car_id = dl.car_id')
            ->join('drive d','d.drive_id = dl.drive_id')
            ->join('contractcar co','co.contractcar_id = dl.contractcar_id')
            ->where($where)
            ->group("dl.driveingcar_id")
            ->page($page,$limit)
            ->select();
        $count = $this->alias('dl')
            ->field($field)
            ->join('car c','c.car_id = dl.car_id')
            ->join('drive d','d.drive_id = dl.drive_id')
            ->join('contractcar co','co.contractcar_id = dl.contractcar_id')
            ->where($where)
            ->group("dl.driveingcar_id")
            ->count();
        return ['data'=>$data,'count'=>$count];
    }
}